package com.zmj.mobile.controller;

import com.zmj.framework.response.Result;
import com.zmj.mobile.dto.TechPurMainIdDTO;
import com.zmj.mobile.dto.TechPurMainInsertDTO;
import com.zmj.mobile.service.ITechPurDetailService;
import com.zmj.mobile.service.ITechPurMainService;
import com.zmj.mobile.vo.TechPurMainIdVO;
import com.zmj.mobile.vo.TechPurMainVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.validation.Valid;


/**
 * <p>
 * 研发试制/采购申请表 前端控制器
 * </p>
 *
 * @author lzy
 * @since 2024-02-01
 */
@RestController
@Api(tags = {"TechPurMain"})
@RequestMapping("/v1/api/tech/pur")
public class TechPurController {

    @Resource
    private ITechPurMainService techPurMainService;

    @Resource
    private ITechPurDetailService techPurDetailService;

    @ApiOperation(value = "新增")
    @PostMapping("/insert")
    public Result<TechPurMainIdVO> insert(@RequestBody @Valid TechPurMainInsertDTO insertDTO) {
        return Result.success(techPurMainService.insert(insertDTO));
    }


    //@ApiOperation(value = "更新")
    //@PostMapping("/updateById")
    //public Result<Boolean> updateById(@RequestBody @Valid TechPurMainUpdateDTO updateDTO) {
    //    techPurMainService.updateById(updateDTO);
    //    return Result.success(true);
    //}
    //
    //@ApiOperation(value = "删除")
    //@PostMapping("/deleteById")
    //public Result<Boolean> deleteById(@RequestBody @Valid TechPurMainIdDTO idDTO) {
    //    techPurMainService.deleteById(idDTO);
    //    return Result.success(true);
    //}

    @ApiOperation(value = "查询单条")
    @PostMapping("/getById")
    public Result<TechPurMainVO> getById(@RequestBody @Valid TechPurMainIdDTO idDTO) {
        TechPurMainVO techPurMain = techPurMainService.getById(idDTO);
        return Result.success(techPurMain);
    }

    //@ApiOperation(value = "查询列表")
    //@PostMapping("/pageList")
    //public Result<IPage<TechPurMainVO>> pageList(@RequestBody @Valid TechPurMainPageDTO pageDTO) {
    //    IPage<TechPurMainVO> page = techPurMainService.pageList(pageDTO);
    //    return Result.success(page);
    //}

    /**
     * @Description 导入研发试制主表
     * @Author songxin
     * @Date 21:19 2024/2/1 0001
     **/
    @Operation(summary = "导入")
    @PostMapping("import")
    public Result<Object> importExcel(@RequestPart(value = "file") MultipartFile file) {
        techPurMainService.importExcel(file);
        return Result.success();
    }

    /**
     * @Description 导入研发试制明细
     * @Author songxin
     * @Date 21:19 2024/2/1 0001
     **/
    @Operation(summary = "导入")
    @PostMapping("importDetail")
    public Result<Object> importDetailExcel(@RequestPart(value = "file") MultipartFile file) {
        techPurDetailService.importExcel(file);
        return Result.success();
    }
}
